package com.example.exercise.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//下载安装minio.exe和mc.exe，放到E:\install\Minio\bin下，进入E:\install\Minio\bin执行如下cmd命令
//setx MINIO_ROOT_USER minioadmin
//setx MINIO_ROOT_PASSWORD minioadmin
//minio.exe server E:\install\Minio\data --console-address "127.0.0.1:9000" --address "127.0.0.1:9005"
//访问客户端地址：http://127.0.0.1:9000
@Configuration
public class MinIoClientConfig {
    @Value("${minio.endpoint}")
    private String endpoint;
    @Value("${minio.accessKey}")
    private String accessKey;
    @Value("${minio.secretKey}")
    private String secretKey;

    /**
     * 注入minio 客户端
     * @return
     */
    @Bean
    public MinioClient minioClient(){
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }

}